package oj0417.oj0417_04;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt();
        int n = sc.nextInt();
        int[][] data = new int[m+2][n+2];
        for (int i = 1; i <= m; i++) {
            for (int j = 1; j <= n; j++) {
                data[i][j] = sc.nextInt();
            }
        }

        int count = 0;
        for (int i = 1; i <= m; i++) {
            for (int j = 1; j <= n; j++) {
                if (data[i][j] > data[i-1][j]
                    && data[i][j] > data[i+1][j]
                    && data[i][j] > data[i][j-1]
                    && data[i][j] > data[i][j+1]) {
                    count++;
                }
            }
        }
        System.out.println(count);
        sc.close();
    }
}
